package com.kingmed.kmss.api.internal;

import com.kingmed.kmss.common.dto.kmcs.*;
import com.kingmed.kmss.common.vo.CommonPage;
import com.kingmed.kmss.common.vo.CommonResponse;
import com.kingmed.kmss.common.vo.CommonResponseHelper;
import com.kingmed.kmss.framework.feign.client.kmcs.LbFeignServiceFacade;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 仅用于内部，给前端提供的通用型接口，因此不写在各自微服务里
 * 此类接口不涉及权限注解！如果涉及要控制权限，必须写在对应的微服务controller层，并加上权限注解
 * 强制：只能调用framework-feign里的client，不允许添加任何业务逻辑，业务逻辑必须写在facade
 * </p>
 */
@RestController
@RequestMapping("/int/kmcs/lb")
@Api(tags = "crm使用-KMCS实验室相关公共接口")
public class KmcsLbApiController {

    @Autowired
    private LbFeignServiceFacade lbFeignServiceFacade;

    @ApiOperation("默认实验室")
    @PostMapping(value = "/getDefaultLab")
    public CommonResponse<List<PsDefaultLabDTO>> getDefaultLab(@RequestBody PsQueryDTO queryDTO) {
        return CommonResponseHelper.success(lbFeignServiceFacade.getDefaultLab(queryDTO));
    }

    @ApiOperation("外包方实验室")
    @PostMapping(value = "/getOutLab")
    public CommonResponse<List<PsOutLabDTO>> getOutLab(@RequestBody PsQueryDTO queryDTO) {
        return CommonResponseHelper.success(lbFeignServiceFacade.getOutLab(queryDTO));
    }

    @ApiOperation("报告单模板(分页)")
    @PostMapping(value = "/getReportTemp")
    public CommonResponse<CommonPage<PsReportTempDTO>> getReportTemp(@RequestBody PsQueryDTO queryDTO) {
        return CommonResponseHelper.success(lbFeignServiceFacade.getReportTemp(queryDTO));
    }

    @ApiOperation("检测系统")
    @PostMapping(value = "/getCheckSystem")
    public CommonResponse<List<PsCheckSystemDTO>> getCheckSystem(@RequestBody PsQueryDTO queryDTO) {
        return CommonResponseHelper.success(lbFeignServiceFacade.getCheckSystem(queryDTO));
    }

    @ApiOperation("根据实验室检测项目ID获取结果单位列表")
    @PostMapping(value = "/getResultDw")
    public CommonResponse<List<PsResultDwDTO>> getCheckSystem(@RequestBody List<String> testItemIdList) {
        return CommonResponseHelper.success(lbFeignServiceFacade.getResultDw(testItemIdList));
    }

}
